#!/usr/bin/env bats

@test "static word: static" {
  cd $BATS_TEST_DIRNAME
  expected="fileDir2/file2:3:for loop that C-based languages
fileDir2/file2:8:problems with for loops in"
  result="$(fish -c 'tbgs for')"
  [ "$result" = "$expected" ]
}

@test "static word: when dynamic is the same as static, nothing happens" {
  cd $BATS_TEST_DIRNAME
  expected="fileDir2/file2:3:for loop that C-based languages
fileDir2/file2:8:problems with for loops in"
  result="$(fish -c 'tbgs word for')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs for word')"
  [ "$result" = "$expected" ]
}

@test "static word: dynamic overwrites static" {
  cd $BATS_TEST_DIRNAME
  expected="fileDir2/file2:3:for loop that C-based languages
fileDir2/file2:4:  actually foreach loops.
fileDir2/file2:8:problems with for loops in"
  result="$(fish -c 'tbgs no-word for')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs for no-word')"
  [ "$result" = "$expected" ]
}

@test "static word: multiple search words, the rest search words also respect word - no-word no-case" {
  cd $BATS_TEST_DIRNAME
  expected="file1:3:In the day of grief, be mild
file1:4:in the day of grief, be mild
file1:6:Heart is living in tomorrow of;
fileDir2/file2:2:at least not the same kind of"
  result="$(fish -c 'tbgs no-word no-case in of')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs in of no-case no-word')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case of no-word in')"
  [ "$result" = "$expected" ]
}

@test "static word: multiple search words, the rest search words also respect word - word no-case" {
  cd $BATS_TEST_DIRNAME
  expected="file1:3:In the day of grief, be mild
file1:4:in the day of grief, be mild
file1:6:Heart is living in tomorrow of;"
  result="$(fish -c 'tbgs word in no-case of')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case in of word')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs of word in no-case')"
  [ "$result" = "$expected" ]
}

@test "static word: multiple search words, the rest search words also respect word - no-word case" {
  cd $BATS_TEST_DIRNAME
  expected="file1:4:in the day of grief, be mild
file1:6:Heart is living in tomorrow of;
fileDir2/file2:2:at least not the same kind of"
  result="$(fish -c 'tbgs in no-word of case')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs of no-word case in')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-word case in of')"
  [ "$result" = "$expected" ]
}

@test "static word: multiple search words, the rest search words also respect word - word case" {
  cd $BATS_TEST_DIRNAME
  expected="file1:3:In the day of grief, be mild"
  result="$(fish -c 'tbgs case word In of')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs of In case word')"
  [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs word In case of')"
  [ "$result" = "$expected" ]
}

